package com.fantastic.web.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.fantastic.web.util.AlipayInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @author: rxx
 * @since: 2024/6/18 10:57
 * @description: 支付宝沙箱配置类
 */
@Configuration
public class AlipayConfig {

    /**
     * 创建支付宝需要的客户端对象
     *
     * @return
     */
    @Bean
    public AlipayClient alipayClient() {
        return new DefaultAlipayClient(
                AlipayInfo.GATEWAY,
                AlipayInfo.APP_ID,
                AlipayInfo.PRIVATE_KEY,
                AlipayInfo.FORMAT,
                AlipayInfo.CHARSET,
                AlipayInfo.PUBLIC_KEY,
                AlipayInfo.SIGN_TYPE);
    }

    /**
     * 创建一个支付宝网页端的请求对象
     *
     * @return
     */
    @Bean
    public AlipayTradePagePayRequest alipayTradePagePayRequest() {
        return new AlipayTradePagePayRequest();
    }

    /**
     * 创建一个支付宝app端的请求对象
     *
     * @return
     */
    @Bean
    public AlipayTradeAppPayRequest alipayTradeAppPayRequest() {
        return new AlipayTradeAppPayRequest();
    }

    /**
     * 创建一个支付宝wap的请求对象
     *
     * @return
     */
    @Bean
    public AlipayTradeWapPayRequest alipayTradeWapPayRequest() {
        return new AlipayTradeWapPayRequest();
    }

}
